package com.sea.base.ext.view

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import com.sea.base.utils.vc.ContextProxy

/**
 * 获取View真正的Context
 */
inline val Context.realContext: Context get() = if (this is ContextProxy) this.realContext else this

@Suppress("NOTHING_TO_INLINE")
inline fun Context.layoutInflate(): LayoutInflater = LayoutInflater.from(this.realContext)

@Suppress("NOTHING_TO_INLINE")
inline fun Context.inflate(@LayoutRes id: Int, vg: ViewGroup, attachToRoot: Boolean = false): View =
    layoutInflate().inflate(id, vg, attachToRoot)